import java.util.Scanner;
import java.util.Random;

public class App {
    public static void main(String[] args) throws Exception {
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        String str = new String ("");//用于判定的字符串
        char ch = '0';
        int count = 4;//换行数
        int num = r.nextInt(94) + 33;//33 ~ 126
        while(1 == 1)//死循环
        {
            blank(count);
            ch = (char)num;
            System.out.println("本次的随机数为" + num + " -> " + ch);
            blank(count);
            System.out.print("请输入指令：");
            str = sc.nextLine();
            if(str.charAt(0)=='w' || str.charAt(0)=='W')//UP
            {
                if(num >= 126)
                {
                    System.out.println("当前数字已达上限，请重新输入指令");
                    continue;
                }
                num++;
            }
            else if(str.charAt(0)=='s' || str.charAt(0)=='S')//DOWN
            {
                if(num <= 33)
                {
                    System.out.println("当前数字已达下限，请重新输入指令");
                    continue;
                }
                num--;
            }
            else
            {
                num = r.nextInt(94) + 33;//重新生成随机数字
            }
        }
    }

    public static void blank(int count)//换行
    {
        int i = 0;
        for(i = 0;i < count;i++)
        {
            System.out.print("\n");
        }
    }
}
